package com.carrental.search.service.impl;

import com.carrental.search.service.DataSyncService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;

/**
 * 数据同步服务降级实现类
 * 当Elasticsearch不可用时使用，提供基本的降级功能
 */
@Slf4j
@Service
@ConditionalOnProperty(name = "spring.elasticsearch.repositories.enabled", havingValue = "false")
public class DataSyncServiceFallback implements DataSyncService {

    @Override
    public int syncAllVehicles() {
        log.warn("使用降级DataSyncService: syncAllVehicles - Elasticsearch不可用，无法同步数据");
        return 0;
    }

    @Override
    public int syncIncrementalVehicles(Long lastSyncTime) {
        log.warn("使用降级DataSyncService: syncIncrementalVehicles - Elasticsearch不可用，无法同步数据");
        return 0;
    }

    @Override
    public boolean syncVehicle(Long vehicleId) {
        log.warn("使用降级DataSyncService: syncVehicle - Elasticsearch不可用，无法同步数据，车辆ID: {}", vehicleId);
        return false;
    }

    @Override
    public boolean deleteVehicle(Long vehicleId) {
        log.warn("使用降级DataSyncService: deleteVehicle - Elasticsearch不可用，无法删除索引数据，车辆ID: {}", vehicleId);
        return false;
    }

    @Override
    public int syncStoreLocations() {
        log.warn("使用降级DataSyncService: syncStoreLocations - Elasticsearch不可用，无法同步门店位置数据");
        return 0;
    }
} 